package com.xyjf.code.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xyjf.code.api.ICodeCreateService;
import com.xyjf.code.util.CheckCodeUtil;
import com.xyjf.code.util.IdGeneratorUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("编码生成")
@RestController
public class CodeCreateController {



    /**
     * 获取订单的ID号
     * @return
     */
    @RequestMapping("/getId")
    @ApiOperation(value = "获取ID编码", httpMethod = "POST", notes = "根据工作ID获取编码", code = 200)
    @ApiResponses({ @ApiResponse(code = 200, message = "完成短信发送"),
            @ApiResponse(code = 400, message = "表明在请求 API时提供了错误信息"),
            @ApiResponse(code = 500, message = "表明 API请求时,服务器发生了错误") })
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "workId", dataType = "long", required = true, value = "范围0-31")})
    public  Object getId(final Long workId){
        IdGeneratorUtil idGeneratorUtil=new IdGeneratorUtil(workId,00);
        Long id=idGeneratorUtil.nextId();
        idGeneratorUtil=null;
        return id ;
    }




    /**
     * 获取订单的ID号
     * @return
     */
    @RequestMapping("/getOrdId")
    @ApiOperation(value = "获取订单编码", httpMethod = "POST", notes = "获取订单编码", code = 200)
    @ApiResponses({ @ApiResponse(code = 200, message = "获取订单编码成功"),
            @ApiResponse(code = 400, message = "表明在请求 API时提供了错误信息"),
            @ApiResponse(code = 500, message = "表明 API请求时,服务器发生了错误") })
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "appId", dataType = "long", required = true, value = "应用Id一位")})
    public  Object getOrderId(final String appId){
        IdGeneratorUtil idGeneratorUtil=new IdGeneratorUtil(01l,00);
        Long id=CheckCodeUtil.getId(idGeneratorUtil.nextId(),appId);
        idGeneratorUtil=null;
        return id ;
    }


    /**
     * 获取用户的ID号
     * @return
     */
    @RequestMapping("/getUserId")
    @ApiOperation(value = "获取用户编码", httpMethod = "POST", notes = "发送短信", code = 200)
    @ApiResponses({ @ApiResponse(code = 200, message = "获取用户编码成功"),
            @ApiResponse(code = 400, message = "表明在请求 API时提供了错误信息"),
            @ApiResponse(code = 500, message = "表明 API请求时,服务器发生了错误") })
    public  Object getUserId(){
        IdGeneratorUtil idGeneratorUtil=new IdGeneratorUtil(00l,00);
        Long id=idGeneratorUtil.nextId();
        idGeneratorUtil=null;
        return id ;
    }
}
